﻿using System;
using System.Collections.Generic;
using System.Text;
using EasyExam.DataServer;
using NHibernate;
using NHibernate.Cfg;

namespace EasyExam.DataServer.NHB
{
    public class NHRepository<TEntity> : IRepository<TEntity>
    {
        #region IRepository Member
        public TEntity Save(TEntity entity)
        {
            ISession session = NHibernateHelper.GetCurrentSession();
            session.Save(entity);
            session.Flush();
            return entity;
        }
        public TEntity GetEntityByKey(Object Key)
        {
            //throw new NotImplementedException();
            if (Key == null)
                throw new ArgumentNullException();

           ISession session= NHibernateHelper.GetCurrentSession();
           return session.Get<TEntity>(Key.ToString());
        }

        public IList<TEntity> GetEntityList(Object queryTerm)
        {
            throw new NotImplementedException();
        }

        public bool RemoveEntity(Object key)
        {
            throw new NotImplementedException();
        }
        #endregion 
    }
}
